/*
* 资产功能
* */
import React, {Component} from "react";
import {observer, inject} from "mobx-react";
import {withRouter} from "react-router-dom";
import {ListAdvanced} from "weaver-mobile-page";
import {getUrlParams} from "../../util"


@inject("myAssetPageStore")
@withRouter
@observer
export default class MyAssetPage extends Component {
    componentDidMount() {
        const {hrmid} = getUrlParams(this.props.location.search)
        this.props.myAssetPageStore.init(hrmid || "");
    }

    render() {
        const {history, myAssetPageStore} = this.props;
        const {
            assetListAll, assetListMine, showCheck, selectedTabIndex,
            dataFetchOptions, conditionFetchOptions, dataFetchOptionsMine
        } = myAssetPageStore;
        const {onSearch} = myAssetPageStore;
        return (<div>
            <ListAdvanced
                store={selectedTabIndex === 1 ? assetListAll : assetListMine}
                hasAdvanceSerach={selectedTabIndex === 1}
                rowKey="id"
                searchKey="name"
                dataFetchOptions={selectedTabIndex === 1 ? dataFetchOptions : dataFetchOptionsMine}
                conditionFetchOptions={conditionFetchOptions}
                showCheck={showCheck}
                onSearch={onSearch}
                onRowClick={(item) => history.push("/assetInfo/infoCard/" + item.id)}
            />
        </div>)
    }
}
